extends "../ib.gd"
var cnt
var cnt3
var flag
var flag2
var flag3
var sk1
func init():
	.init()
	name = "极速鞋"
	resetdata()
	att.atkRan = 1
	att.maxHp = 100
	att.dod = 0.05
	info = "战术撤退：受到致命伤害时免疫本次伤害并瞬移到自身方阵后排，第一次触发时还会恢复自身10%生命上限血量[cd:15秒]"
#根据等级增加属性
func addatt():
	if self.id.find("MAX") != -1:
		att.maxHp += 300
	else:
		att.maxHp += 200
	pass
#链接信号
func _connect():
	._connect()
	yield(sys.get_tree().create_timer(0.05),"timeout")
	if !masCha:return
	if !masCha.is_connected("onHurt",self,"run"):
		masCha.connect("onHurt",self,"run")
	if !masCha.is_connected("onBattleStart",self,"resetcnt"):
		masCha.connect("onBattleStart",self,"resetcnt")
	if !masCha.is_connected("onAddItem",self,"check"):
		masCha.connect("onAddItem",self,"check")
#检查是否只有一双鞋
func check(item):
	yield(sys.get_tree().create_timer(0.02),"timeout")
	if item.id.find("shoe") != -1 && item != self:
		masCha.delItem(item)
		sys.newBaseMsg("提示","一个角色只能装备一双鞋")
#重置技能计数
func resetcnt():
	cnt = 0
	cnt3 = 0
	flag = 1 
	flag2 = 1
	flag3 = 1
	sk1 = 0
#进化装备
func upgradeself(item):
	var chose = item.chose
	var c = str(chose)
	var upid = "_Hide"
	if self.id != "i_TD_shoe":
		upid = "_MAX"
	upid = self.id + upid
	self.switchchose(chose)
	var nitem = sys.newItem(upid)
	sys.main.player.addItem(nitem)
	masCha.disconnect("onAddItem",self,"check")
	masCha.addItem(nitem)
	nitem.inheritatt(nitem,self)
	nitem.addatt()
	nitem.upinfo()
	self.delself()
#战术撤退
func run(atkinfo):
	if atkinfo.isMiss:return
	if atkinfo.hurtVal > masCha.att.hp && flag:
		sk1 = 1
		flag = 0
		atkinfo.hurtVal = 0
		var chas = masCha.getAllChas(1)
		for i in chas:
			if i.aiCha == masCha:
				i.aiCha = null
		if flag2:
			flag2 = 0
			masCha.healCha(masCha,masCha.att.maxHp * 0.1)
			if self.id.find("Hide") != -1:
				masCha.addBuff(ctrl.b_vague.new(3))
		var v = Vector2(0,0)
		if masCha.team == 2:v = Vector2(9,0)
		var tmp = 0
		for i in range(5):
			for j in range(6):
				if masCha.team == 2:
					v += Vector2(-i,j)
				else:
					v += Vector2(i,j)
				var cha = sys.main.matCha(v)
				if cha == null:
					if masCha.setCell(v):
						var position = sys.main.map.map_to_world(v)
						masCha.ying(position,masCha.position)
						masCha.position = position
						masCha.aiCha = null
						tmp = 1
						break
			if tmp:
				break
	yield(sys.get_tree().create_timer(0.1),"timeout")
	sk1 = 0
#技能计时
func _upS():
	._upS()
	if flag:return
	cnt += 1
	if cnt == 15:
		cnt = 0
		flag = 1